/*
* Copyright (C) 2020 ~ 2024 chaigec All Rights Reserved.
*
* Author:     chaigec <chaigec@163.com>
* Maintainer: chaigec <chaigec@163.com>

 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
*/

#ifndef MK_RTMP_PUBLISHER_H
#define MK_RTMP_PUBLISHER_H
#include "MkRtmpClient.h"
#include "MkMedia/MkMediaUtil.h"

typedef MkFunction<void()>  MkRtmpPusherReadyCallback;
class MkApi CMkRtmpPublisher : public CMkRtmpClient
{
public:
    CMkRtmpPublisher(CMkEvent* pEvent, CMkTimer* pTimer, const MkEventRemovedCallback& RemoveCb);
    ~CMkRtmpPublisher();

    Uint32 Start(const MkString& RtmpUrl, const CMkVideoParam& VideoParam, const CMkAudioParam& AudioParam, const Uint32& FileSize, const Uint32& Duration, const MkRtmpPusherReadyCallback& ReadyCb);
    Uint32 Stop();
    Uint32 SendEsPacket(const MkEsPacket& EsPacket);
private:
    Uint32 OnHandSharked() override;
    Uint32 OnConnectResult(BOOL bSuccess) override;
    Uint32 OnCreateStreamResult(BOOL bSuccess) override;
    Uint32 OnPublishResult(const MkString Level, const MkString& Description, const MkString& Code) override;
private:
    CMkVideoParam               m_VideoParam;
    CMkAudioParam               m_AudioParam;
    Uint32                      m_FileSize;
    Uint32                      m_Duration;
    BOOL                        m_bSendMetaData;
    MkRtmpPusherReadyCallback   m_ReadyCb;
    Uint8                       *m_pBuffer;
    Uint32                      m_nMaxLen;
    Uint32                      m_nOffset;
};




#endif